package api

import (
	"encoding/json"
	"github.com/gorilla/mux"
	"net/http"
)

type API struct {
	R *mux.Router
}

type NewsFullDetailed struct{}
type NewsShortDetailed struct{}
type Comment struct{}

func New() *API {
	api := API{}
	api.R = mux.NewRouter()
	api.endpoints()
	return &api
}

func (api *API) endpoints() {
	api.R.HandleFunc("", api.NewsFullDetailedHandler).Methods(http.MethodGet)
	api.R.HandleFunc("", api.NewsShortDetailedHandler).Methods(http.MethodGet)
	api.R.HandleFunc("", api.CommentHandler).Methods(http.MethodGet)
	api.R.HandleFunc("", api.FilterHandler).Methods(http.MethodGet)
}

func (api *API) Router() *mux.Router {
	return api.R
}

func (api *API) NewsFullDetailedHandler(w http.ResponseWriter, r *http.Request) {
	json.NewEncoder(w).Encode(NewsFullDetailed{})
}
func (api *API) NewsShortDetailedHandler(w http.ResponseWriter, r *http.Request) {
	json.NewEncoder(w).Encode(NewsShortDetailed{})
}
func (api *API) CommentHandler(w http.ResponseWriter, r *http.Request) {
	json.NewEncoder(w).Encode(Comment{})
}
func (api *API) FilterHandler(w http.ResponseWriter, r *http.Request) {}
